<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

    <h:body>

        <ui:composition template="./../template.xhtml">

            <ui:define name="content">
                <p:growl id="msgs" showDetail="true" /> 
                <h:form id="formDataTable">  
                    <p:dataTable id="documentos" var="documento" value="#{documentoBean.documentos}" emptyMessage="Nenhum documento cadastrado.">  

                        <p:column headerText="Protocolo" style="width:24%">  
                            <h:outputText value="#{documento.protocolo}" />  
                        </p:column>  

                        <p:column headerText="Assinante" style="width:24%">  
                            <h:outputText value="#{documento.nomeAssinante}" />  
                        </p:column>  

                       <p:column headerText="Detalhes" style="width:4%">  
                            <p:commandButton id="selectButton" update=":formImageView" oncomplete="dialogDocumentoDetails.show()" icon="ui-icon-search" title="Detalhes">  
                                <f:setPropertyActionListener value="#{documento}" target="#{documentoBean.selectedDocumento}" />  
                            </p:commandButton>  
                        </p:column>  

                    </p:dataTable>  
                </h:form>


                <h:form id="formImageView">
                    <p:dialog header="Detalhes " widgetVar="dialogDocumentoDetails" resizable="false" id="dlgDocumentoDetails"  
                              showEffect="fade" hideEffect="explode" modal="true">  
                        <h:panelGrid id="display" columns="2" cellpadding="4" style="margin:0 auto;">  

                            <f:facet name="header">  
                                <p:graphicImage value="/resources/images/documentos/#{documentoBean.selectedDocumento.nomeImagem}"/>  
                            </f:facet> 

                            <h:outputText value="Protocolo:" />  
                            <h:outputText value="#{documentoBean.selectedDocumento.protocolo}" style="font-weight:bold"/>  

                            <h:outputText value="Assinante:" />  
                            <h:outputText value="#{documentoBean.selectedDocumento.nomeAssinante}" style="font-weight:bold"/>  
  
                        </h:panelGrid>  
                    </p:dialog>  
                </h:form>

            </ui:define>
        </ui:composition>
    </h:body>
</html>
